/*
 * @Description: 最长字符串
 * @Author: zzj
 * @Date: 2021-09-09 14:27:46
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-09 15:30:42
 */

//封装一个函数，给定一个字符串数组var arr = ["com", "briup.com", "cn", "briup.com.cn", "http://www"],输出最长的字符串元素对应的索引和字符串值。

// const readline = require("readline-sync");
// var arr = readline.question("请输入字符串数组：")
var arr = ["com", "briup.com", "cn", "briup.com.cn", "http://www"];
function zczfc(arr){
    var arr1 = [];
    for (k in arr){
        arr1.push(arr[k].length)
    }
    var num = arr1.indexOf(Math.max(...arr1));
    console.log("索引为："+num);
    console.log("字符串值为："+arr[num]);
}
zczfc(arr);
